DevForce Help Reference
Include<TQuery>(TQuery,String) Method
Example 


An EntityQuery
Dot-separated list of navigation properties that describe the query path in the graph that should be eagerly fetched.
Configures eager fetching for related entities in the specified query path.
Syntax
'Declaration
 
<ExtensionAttribute()>
Public Overloads Shared Function Include(Of TQuery As ITypedEntityQuery)( _
   ByVal query As TQuery, _
   ByVal propertyPath As String _
) As TQuery
'Usage
 
Dim query As TQuery
Dim propertyPath As String
Dim value As TQuery
 
value = EntityQueryExtensions.Include(Of TQuery)(query, propertyPath)
[Extension()]
public static TQuery Include<TQuery>( 
   TQuery query,
   string propertyPath
)
where TQuery: ITypedEntityQuery

Parameters

query
An EntityQuery
propertyPath
Dot-separated list of navigation properties that describe the query path in the graph that should be eagerly fetched.

Type Parameters

TQuery

Return Value

A new IEntityQuery with the defined query path.
Remarks
The propertyPath may represent a simple or complex navigation. For example, if a Customer type has an Orders navigation property, and the Order type has OrderDetails, you can use a property path of "Orders" to eagerly load orders for any customer queried, and you can use "Orders.OrderDetails" to eagerly load both orders and details for queried customers. Note that the complex property path might not be a valid navigation if a collection is returned, as with "Orders.OrderDetails", but instances of the collection must have the indicated property (e.g., anOrder.OrderDetails). All "parts" in the property path will be pre-loaded into the EntityManager cache when the query is executed.

Multiple "Includes" may be added to a query.

Example
DomainModelEntityManager mgr = new DomainModelEntityManager();

// Query for some customers, and include their orders and details in query.
var query1 = mgr.Customers
  .Where(c => c.Id < 5)
  .Include("OrderSummaries.OrderDetails");

foreach (Customer c in query1) {
  Console.WriteLine("order count = " + c.OrderSummaries.Count);
}

// Query for orders including details where the customer is in London
var query2 = mgr.OrderSummaries.Include("OrderDetails")
    .Where(c => c.Customer.City == "London");

var results = query2.ToList();
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntityQueryExtensions Class
EntityQueryExtensions Members
Overload List

Send Feedback